package edu.whut.arraysTest;

import java.util.Arrays;

/*
Arrays工具类
toString：将数组元素拼接为有格式的字符串
equals:比较两个数组内容是否完全相同
binarySearch(int[] a,int key):二分查找（前提有序）
sort(int[] a)默认升序

 */
public class ArraysDemo {
    public static void main(String[] args) {
        int[] arr1 = {1,2,30};
        int[] arr2 = {1,2,30};
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.equals(arr1,arr2));
        System.out.println(Arrays.binarySearch(arr1, 2));
        System.out.println(Arrays.binarySearch(arr1, 100));
        //若不存在，返回（-插入点-1）
        int[] a = {5,9,2,4,11};
        //TODO 怎么降序排列
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));
    }
}
